<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="javax.naming.Context"%> 
<%@ page import="javax.sql.DataSource"%> 
<%@ page import="javax.naming.InitialContext"%> 
<%@ page import="java.sql.*"%> 
<%@page import="dataconn.dataconn"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@include file="../JS/adminsession.jsp" %>
<head>
<script type="text/javascript" language="javascript"> 
 function add(fromID,toID) 
 { 
var v;
var j=0;
var s1=document.getElementById(fromID); 
var l=s1.length; 
for(var i=0;i<l;i++) 
{ 
   if(s1.options[i].selected==true) 
    { 
      v=s1.options[i].value; 
      s2=document.getElementById(toID); 
      m=0; 
      for(k=0;k<s2.length;k++) 
      { 
        if(s2.options[k].value==v) 
         { 
              m=1; 
         }
       } 
       if(m==0) 
         { 
          var varItem = new Option(v, v); 
          s2.options.add(varItem); 
         } 
     else 
       { 
          alert('已经存在此选项'); 
       } 
    j=1;
    } 

} 
 if(j!=1) 
 { 
  alert('请选择你要添加的选项'); 
 } 
} 
function del(desID) 
{ 
   s2=document.getElementById(desID); 
   l=s2.length; 
   j=0; 
   for(i=0;i<l;i++) 
   { 
     if(s2.options[i].selected==true) 
      { 
       s2.options.remove(i); 
       s2.length=l-1; 
       j=1; 
       break;
      } 
    } 
   if(j==0) 
    { 
      alert('请选择你要删除的选项'); 
    } 
return false; 
} 
function subform()
{
   var _sel = document.getElementById('User2') ;
   for(var i = 0 ;i<_sel.length ;i++)
   {
       _sel.options[i].selected = true ;
    }
   var _pro = document.getElementById('Project2') ;
   for(var i = 0 ;i<_pro.length ;i++)
   {
       _pro.options[i].selected = true ;
    }
    form2.submit();
  }
</script>
<title>无标题文档</title>
<link href="../css/background.css" rel="stylesheet" type="text/css" />
</head>
 <BODY id=css-zen-garden>
<DIV id=container>
<DIV id=intro>
<DIV id=quickSummary>
<P class=p2>欢迎，<%=session.getAttribute("RealName") %>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../JS/logout.jsp">退出</a>&nbsp;&nbsp;&nbsp;<a href="../EditUser.jsp">修改资料</a>&nbsp;&nbsp;&nbsp;<a href="../MyBug.jsp">返回前台</a></P>
</DIV>
<DIV id=preamble>
<H3><SPAN>添加分组</SPAN></H3>
    <form id="form2" name="group" method="post" action="group_edit.jsp">
     <table width="100%" border="0" cellpadding="0" cellspacing="1" class="table_style">
        <tr bgcolor="#52514E">
          <td colspan="4">修改分组</td>
        </tr>
        <%
   String GroupID=request.getParameter("GroupID");
   String sql="select GroupName from TestGroup where GroupID='"+GroupID+"'";
   dataconn conn=new dataconn();
   ResultSet rs00=conn.executeQuery(sql);
   rs00.next();
   String GroupName=rs00.getString("GroupName");
    %> 
        <tr bgcolor="#52514E">
          <td width="30%">分组名称</td>
          <input type="hidden" name="GroupID" value="<%=GroupID %>"/>
          <td align="left" colspan="3"> <input name="groupname" type="text" class="selectlist" value="<%=GroupName %>" /></td>
        </tr>
        <tr bgcolor="#52514E">
          <td width="30%">分组用户</td>
          <td align="left"><select name="User" size="4" multiple class="selectlist3" id="User">
              <%
           String sql0="select UserName from TestUser where IsDropped=0";
           ResultSet rs0=conn.executeQuery(sql0);
           if(rs0==null)
           {
          %>
              <option>暂时没有添加用户！</option>
              <%
        }
        else
        {while(rs0.next())
           {
         %>
              <option value='<%=rs0.getString("UserName")%>'><%=rs0.getString("UserName")%></option>
              <%}}
          %>
          </select></td>
          <td><input name="button2" type="button" class="button" id="button2" value="添加" onclick="add('User','User2')"/>   <br />
              <input name="button2" type="button" class="button" id="button2" value="删除" onclick="del('User2')"/>
          </td>
          <%
           String sql1="select UserName from TestUser,Group_User where TestUser.UserID=Group_User.UserID and GroupID="+GroupID;
           ResultSet rs1=conn.executeQuery(sql1);
           %>
          <td><select name="User2" size="4" multiple class="selectlist3" id="User2">
          <% while(rs1.next())
           {
         %>
              <option value='<%=rs1.getString("UserName")%>'><%=rs1.getString("UserName")%></option>
              <%}
              rs1.close();
          %></td>
        </tr>
        <tr bgcolor="#52514E">
          <td width="30%">所属项目</td>
          <td align="left"><select name="Project" size="4" multiple class="selectlist3">
              <%
        String sq="select ProjectName from TestProject where IsDropped=0";
        rs0=conn.executeQuery(sq);
        if(rs0==null)
        {
        %>
              <option>暂时没有添加用户！</option>
              <%
        }
        else
        {while(rs0.next())
           {
         %>
              <option value='<%=rs0.getString("ProjectName")%>'><%=rs0.getString("ProjectName")%></option>
              <%}}
          %>
          </select></td>
          <td><input name="button" type="button" class="button" id="button" value="添加" onclick="add('Project','Project2')"/>   <br />
              <input name="button2" type="button" class="button" id="button2" value="删除" onclick="del('Project2')" /></td>
          <%
           String sql3="select ProjectName from TestProject,Group_Project where TestProject.ProjectID=Group_Project.ProjectID and GroupID="+GroupID;
           ResultSet rs3=conn.executeQuery(sql3);
           %>
          <td><select name="Project2" size="4" multiple class="selectlist3" id="Project2">
          <% while(rs3.next())
           {
         %>
              <option value='<%=rs3.getString("ProjectName")%>'><%=rs3.getString("ProjectName")%></option>
              <%}
              rs3.close();
          %></td>
        </tr>
        <tr bgcolor="#52514E">
          <td height="30" colspan="4"><input type="submit" name="button" id="button" onclick="subform()" value="修改" />
          </td>
        </tr>
      </table>
    </form>
  
</DIV></DIV>
<DIV id=supportingText>
</DIV>
<DIV id=linkList>
<DIV id=linkList2>
<DIV id=lusers>
<H3 class=users></H3>
<UL>
  <LI><a href="GroupMaintain.jsp"><SPAN 
  class=accesskey>浏览/维护分组</apan></a> </li> 
  <LI><A href="AddGroup.jsp"><SPAN 
  class=accesskey>添加新的分组</SPAN></A> </LI> 
    <LI><A href="AddUser.jsp"><SPAN 
  class=accesskey>浏览/维护用户</SPAN></A> </LI> 
  </UL>
</DIV>
<DIV id=lprojects>
<H3 class=projects></H3>
<UL>
    <LI><A href="NewProject.jsp"><SPAN 
  class=accesskey>新建项目</SPAN></A> </LI> 
<script> 
function go(obj){ 
self.location=obj.options[obj.selectedIndex].value; 
return false; 
} 
</script> 
        <LI>
        <form  method="post" action="ManageProject.jsp">
          <select name="project" class="treelist"  onchange="go(this)" >
            <option selected="selected">维护项目</option>
   <%
   dataconn con=new dataconn();
   String sql2="select ProjectName,ProjectID from TestProject where IsDropped='0'";
   ResultSet rs2=con.executeQuery(sql2);

   while(rs2.next())
   {
      String ProjectID=rs2.getString("ProjectID");
      String ProjectName=rs2.getString("ProjectName");
   %>
            <option value="ManageProject.jsp?ProjectID=<%=ProjectID%>"><%=ProjectName%></option>
            <%} %>
 <%
    rs2.close();
    con.closeConn();
    con.closeStmt(); 
 %>
          </select>
        </form>
      </LI>
</UL>
</DIV></DIV></DIV></DIV>
</BODY>
</html>